package com.doordu.soa.service.comm.utils;
/**
 * 部门编码生成工具类
 * @ClassName: DeptCodeUtil
 * @Description: 
 * @author xiaoqun.yi yixq@doordu.com  
 * @date 2017年4月7日 下午12:39:09
 * @version V1.0
 */
public class DeptCodeUtil {
	public static String generateRandomDeptCode(int len) {   
	      //字符源，可以根据需要删减
        String generateSource = "0123ABCDEFGHIJKMNPQRSTUVWXYZ456789";//去掉1和i ，0和o
        String rtnStr = "";
        for (int i = 0; i < len; i++) {
            //循环随机获得当次字符，并移走选出的字符
            String nowStr = String.valueOf(generateSource.charAt((int) Math.floor(Math.random() * generateSource.length())));
            rtnStr += nowStr;
            generateSource = generateSource.replaceAll(nowStr, "");
        }
        return rtnStr;
    }
	
	public static void main(String[] args) {
		System.out.println(generateRandomDeptCode(4));
	}
}
